package com.ws.shop.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ws.shop.bean.Page;
import com.ws.shop.dao.CategoryDao;
import com.ws.shop.entity.Category;
import com.ws.shop.service.CategoryService;

@Service(value="categoryService")
public class CategoryServiceImpl implements CategoryService {
	@Resource(name="categoryDao")
	private CategoryDao categoryDao;
	
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public List<Category> findAllCategoryList() {
		return categoryDao.findAllCategoryList();
	}

	@Transactional(rollbackFor = Exception.class)
	public void saveOrUpdate(Category category) {
		categoryDao.saveOrUpdate(category);
	}
	
	/**
	 * 查询商品类型
	 * @param id
	 * @return
	 */
	public Category getCategory(int id){
		return categoryDao.getCategory(id);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page findCategoryListByPage(int pageno, int pagesize,
			String categoryname) {
		return categoryDao.findCategoryListByPage(pageno,pagesize,categoryname);
	}
}
